package com.fractalist.base.core.constants;

import javax.servlet.http.HttpServletRequest;

import com.fractalist.base.core.ConfigurableContants;

/**
 * 系统级的配置文件，从system.properties文件中读取
 * 
 * @author radio
 * 
 */
public class SystemConstants extends ConfigurableContants {
	private static String ROOT = null;
	static {
		init("/conf/system.properties");
	}

	public static String getROOT(HttpServletRequest request) {
		if (null == ROOT) {
			ROOT = request.getContextPath();
		}
		return ROOT;
	}

	public final static String MESSAGE_BUNDLE_KEY = getProperty(
			"systemConstants.message_bundle_key", "i18n/messages");

	/**
	 * 上传文件的服务器真实路径
	 */
	public static String UPLOAD_SERVER_PATH = getProperty("upload_server_path",
			"/home/www/upload/");

	/**
	 * 上传文件的网络访问路径
	 */
	public static String UPLOAD_WEB_URL = getProperty("upload_web_url",
			"http://upload.ss.com/");

	/**
	 * 存储用户分页信息,所有列表的分页信息,都在该session中存放
	 */
	public static String PAGE_INFO = "pageInfo";

	/**
	 * 用户ID存储在session中的key
	 */
	public static String USER_SESSION_KEY = "USERSESSION";

	/**
	 * cookie的时间，默认为600秒
	 */
	public static final int COOKIE_MAX_AGE = 600;

	/**
	 * json发起ajax请求中的参数名
	 */
	public static final String JSON_PARAM_NAME = "params";

	// 文件上传的大小
	public static final long FILE_UPLOAD_SIZE = Long.valueOf(getProperty(
			"file_upload_size", (80 * 1000) + ""));
}
